/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2025-01-04 20:39:56
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2025-01-06 10:21:03
 * @FilePath: \project-my\vue-mall\src\store\counter.ts
 * @Description: 
 */
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import axios from 'axios'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  
  const increment = () => {
    count.value++
  }

 //  getter
  const doubleCount = computed(() => count.value * 2)

 // action
 const list = ref([])
 const getList = async() => {
    const res = await axios.get('http://localhost:3008/v1/picture/list')
    list.value = res.data
 }
 

  return { count, increment, doubleCount, list, getList }
})